package vn.appsmobi.activity;

import vn.appsmobi.ui.BaseFragment;
import vn.appsmobi.ui.DetailFragment;
import vn.appsmobi.ui.ListAppFragment;
import vn.appsmobi.ulti.Constant;
import vn.appsmobi.ulti.InstallChecker;
import vn.appsmobi.ulti.Log;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CategoryAppActivity extends BaseActivity {

	String categoryId;
	String categoryname ;
	String type;
	
	protected Fragment newFragmentByTag(String tag)
	  {	 
		Fragment mListAppFragMent = null;
	    if (TextUtils.equals(tag, Constant.FRAGMENT_TAG_ALL))
	    {
	    	mListAppFragMent = new ListAppFragment();
	    	((ListAppFragment)mListAppFragMent).setCategory(this.categoryId);
	    	
	    	if(this.type != null)
	    		((ListAppFragment)mListAppFragMent).setListAppType(this.type );
	    }
		return mListAppFragMent;
	    
	  }
	
	 public void showFragment(String tag, Bundle bundle, boolean addToBackStack)
	  {	 
	      super.showFragment(tag, bundle, addToBackStack);	      
	  }
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);		
		
		Intent intent = getIntent();
		
		this.categoryId 	= intent.getStringExtra(Constant.INTENT_EXTRA_CATEGORY_PARENT_ID);
		this.categoryname 	= intent.getStringExtra(Constant.INTENT_EXTRA_CATEGORY_PARENT_NAME);	
		this.type 			= intent.getStringExtra(Constant.INTENT_EXTRA_TYPE);
		Log.v("Category App Type:" + this.type);
		if(null == savedInstanceState)
		{
			setBarTitle(this.categoryname);
			setHomeButtonEnable(true);
			showFragment(Constant.FRAGMENT_TAG_ALL, savedInstanceState, false);
		}
		
		
	}
	
	
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		//getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	
	

}
